﻿using System.Text;

namespace StoryCardLogic.ImportExportData
{
    public class TxtStorySaver : IStorySaver
    {
        private readonly IFile _fileManager;
        private readonly IStoryManager _manager;

        public TxtStorySaver(IStoryManager manager, IFile fileManager)
        {
            _manager = manager;
            _fileManager = fileManager;
        }

        public void Save(string path)
        {
            var builder = new StringBuilder();
            int i = 1;
            foreach (Story story in _manager.Stories)
                builder.AppendFormat("{0}\n", story.Text);
            _fileManager.SaveToFile(path, builder.ToString());
        }
    }
}